let isWeb = false;
function getCurEnvironment() {
  var UA = window.navigator.userAgent.toLowerCase();
  var isAndroid = (UA && UA.indexOf('android') > 0);
  var isIOS = (UA && /iphone|ipad|ipod|ios/ig.test(UA));
  if (isAndroid) {
    return "andriod";
  }
  if (isIOS) {
    return "ios";
  };
  return "web";
};
isWeb = getCurEnvironment();
let appid = '',
  mapihost = '',
  enveriment = '',
  clientIp = "https://recsys.cnki.net/",
  returnURL = '',
  ssoHost = "",
  ssoAPIHost = "",
  jwt = '',
  yxhost = "",
  mhost = "",
  readURL = '',
  ssoAPIHostLocalFile = '',
  teammanageapiUrl = '',
  teamURL = '',
  fileHost = '',
  accountURL = '',
  returnCathedraURL = "",
  pageCathedra = "",
  returnURLTeam = '',
  page = '';
if (isWeb == "andriod" || isWeb == "ios") {
  page = "winter.html#/"
  pageCathedra = "cathedraMobile.html"
} else {
  page = "winterMobile.html#/";
  pageCathedra = "cathedra.html"
}
if (window.location.host.indexOf("dev") >= 0 ) {
  appid = 'CRSP_ACCOUNT_DEV';
  mapihost = "";
  // mapihost = `${window.location.protocol}//member.dev.cnki.net:8089`; //member.dev.cnki.net:8089
  ssoAPIHost = `${window.location.protocol}//sso.dev.cnki.net`; //http://sso.dev.cnki.net/api/api/user/accesstoken/s/withaccounttype
  ssoHost = `${window.location.protocol}//sso.dev.cnki.net`;
  // ssoHost = `https://xtest.cnki.net`
  ssoAPIHostLocalFile = 'http://sso.dev.cnki.net';
  enveriment = 'AID';
  fileHost = 'http://member.dev.cnki.net:8902';
  teammanageapiUrl = `${window.location.protocol}//sso.dev.cnki.net`;
  yxhost = `${window.location.protocol}//x.dev.cnki.net`;
  // yxhost = `https://xtest.cnki.net`;
  mhost = `${window.location.protocol}//member.dev.cnki.net`;

  returnURL = "http://sso.dev.cnki.net/annualReport/activity/" + page;
  returnURLTeam = `http://sso.dev.cnki.net/annualReport/activity/teamActivity.html#/activity/`
  returnCathedraURL = "https://k.cnki.net/NewTheme/ThemeSign/435";
} else if (window.location.host.indexOf("xtest") >= 0|| window.location.host.indexOf("192") >= 0) {
  appid = 'CRSP_ACCOUNT_RELEASE';
  mapihost = `${window.location.protocol}//xms-api-test.cnki.net`;
  ssoAPIHost = `${window.location.protocol}//xtest.cnki.net`;
  ssoHost = `${window.location.protocol}//xtest.cnki.net`;
  ssoAPIHostLocalFile = 'https://xtest.cnki.net';
  // ssoAPIHostLocalFile = 'https://gateway.cnki.net';
  enveriment = 'LID';
  teammanageapiUrl = `${window.location.protocol}//xtest.cnki.net`;
  yxhost = `${window.location.protocol}//xtest.cnki.net`;
  mhost = `${window.location.protocol}//xms-web-test.cnki.net`;
  returnURL = "https://xtest.cnki.net/annualReport/activity/" + page;
  returnCathedraURL = "https://k.cnki.net/NewTheme/ThemeSign/435"
  fileHost = 'https://gateway.cnki.net/hfs'
  returnURLTeam = `http://xtest.cnki.net/annualReport/activity/teamActivity.html#/activity/`
  // } else if(window.location.href.indexOf("localhost")>0){
} else {
  appid = 'CRSP_ACCOUNT';
  mapihost = `${window.location.protocol}//mxapi.cnki.net`;
  ssoAPIHost = `${window.location.protocol}//gateway.cnki.net`;
  enveriment = 'LID';
  ssoHost = `${window.location.protocol}//ssox.cnki.net`;
  teammanageapiUrl = `${window.location.protocol}//x.cnki.net`;
  yxhost = `${window.location.protocol}//x.cnki.net`;
  mhost = `${window.location.protocol}//mx.cnki.net`;
  ssoAPIHostLocalFile = 'https://gateway.cnki.net';
  returnURL = "https://ssox.cnki.net/annualReport/activity/" + page;
  returnCathedraURL = "https://k.cnki.net/NewTheme/ThemeSign/435"
  fileHost = 'https://gateway.cnki.net/hfs'
  returnURLTeam = `https://ssox.cnki.net/annualReport/activity/teamActivity.html#/activity/`
}
const API_CONFIG = {
  'API': {
    'activity': window.location.origin.indexOf("192") >= 0 ? `/activity` : `${mapihost}/activity`,
    'ssoapi': window.location.origin.indexOf("192") >= 0 ? `/api` : `${ssoAPIHost}/api`,
    'clientip': window.location.origin.indexOf("192") >= 0 ? `/RCDService` : `${clientIp}/RCDService`,
    'point': window.location.origin.indexOf("localhost") >= 0 ? `/point` : `${window.ApplicationPathSale}/point`,
  },
  'appid': appid,
  'enveriment': enveriment,
  'returnURL': returnURL,
  'readURL': readURL,
  'teamURL': teamURL,
  'returnURLTeam': returnURLTeam,
  'MEMBER_API_HOST': mapihost,
  // 'MEMBER_API_HOST': '',
  //本地调试使用
  'IS_MOCK': false, //为true代表使用mock数据，false代表不使用 
  'DEV_Token': 'WEEvREcwSlJHSldTTEYzVTFPZWhyc0w0eXFLR3ZRZ1pGdDZMbEVoOWJBTT0=$9A4hF_YAuvQ5obgVAqNKPCYcEjKensW4ggI8Fm4gTkoUKaID8j8gFw!!',
  //  'DEV_Token': ACCESS_TOKEN,
  'YX_WEB': yxhost,
  "returnCathedraURL": returnCathedraURL,
  'SSO_API_HOST': ssoAPIHost,
  'SSO_API_HOST_LOCAL_FILE': ssoAPIHostLocalFile,
  'SSO_HOST': ssoHost,
  'MEMEBER_HOST': mhost,
  'TEAM_API_HOST': teammanageapiUrl,
  'CLIENTIP': clientIp,
  'ACCOUNT_URL': accountURL,
  'SSO_API_HOST_JWT': jwt,
  'fileHost':fileHost,//文件下载地址
}
export default API_CONFIG